package com.masq.agencija.pages;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.masq.agencija.interfaces.Client;
import com.masq.agencija.interfaces.AuxClient;
import com.masq.agencija.pages.UnosRenta;
import com.masq.agencija.pages.Login;
import com.masq.agencija.service.Clients;

public class PregledClient {
	@Inject
	@Property
	private Clients klijenti;

	@Property
	private Client trenutniClient;
	
	@InjectPage
	private UnosRenta entryRent;
	
	@OnEvent(component = "entryClientLink")
	Object onClientLink(String ime) {
		entryRent.setRentClient(ime);
		return entryRent;
	}
	
	@OnEvent (component = "clientDetailsLink")
	Object onDetailsLink(String ime) {
		entryRent.setRentClient(ime);
		return entryRent;
	}
	@SessionState
	private AuxClient user;

	private boolean userExists;
	
	public AuxClient getUser() {
		return user;
	}
	
	Object onActivate() {
		if (!userExists) return Login.class;
		return null;
	}
}
